<style>
.weui_cells:after {
  border-bottom: 0 solid #D9D9D9;
}
.arrow-left {
  display:inline-block;
  width:0px;
  height:0px;
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-right:5px solid #ff4e2c; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
  margin-bottom:-1px
}
</style>
<div class="weui_cells_title">{{pagedata.typeinfo.unit || '活动'}}商品
<span onclick="$('#selectgoods').modal();" class="r-f" style="font-size:0.65rem">去商品库选择 <i class="icon icon-more" style="font-size:0.6rem;color:#999"></i></span>
</div>
<div class="fui-list-group item-ng" style="border: 1px dashed #00a0e9;" ng-repeat="(key,g) in pagedata.post.goods track by $index">
	<div class='fui-list align-start' style="padding-top:0.5rem;">
					<div class='fui-list-media'>
					   <img style="width: 5rem;height: 5rem;" ng-src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}" />
					</div>
					<div class='fui-list-inner'>
						<div class='text bold'>{{g.title}}</div>
						<div class="fui-cellone" style="padding:0.5rem 0;">
							<div class='fui-cellone-label' style="width:auto">
							   <div class="bigprice red bold" style="font-size:1rem;position:relative">
								￥{{g.price}}
								</div>
							</div>
							<div class='fui-cellone-info' style="padding-left:0.2rem">
								<span class="arrow-left"></span><span style="display:inline-block;padding:0.1rem 0.3rem;color:#fff;font-size:0.5rem;background:#ff4e2c;border-radius:0.1rem;">{{pagedata.typeinfo.unit||'活动'}}价</span>
							</div>
							<div class='fui-cellone-remark noremark'>
								<span style="font-size:0.6rem;color:#666">库存{{g.total || '不限'}}</span>
							</div>
						</div>
						<div class="fui-cellone" style="padding:0;">
							<div ng-if="pagedata.post.gamename=='jy_merchgame_ms'" class='fui-cellone-info'>
							<span class="progress" style="float: left;margin-top:0.35rem;margin-bottom:0.25rem;width: 4.5rem;height: 0.5rem;border-radius: .5rem;overflow: hidden;">
								<div class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="width: {{g.percent || 1}}%;background-color:red;"><span class="sr-only">60% Complete</span></div>
							</span>
							<span class="process-text" style="float: left;font-size:0.55rem;margin:0.3rem;">已秒 0%</span>
							</div>
						</div>
						<div class="fui-cellone" style="padding:0;">
							<div ng-if="g.buynum>0" class='fui-cellone-info'>
								<span class="label label-info">限购</span> <span style="font-size:0.6rem;color:#666">每人最多买{{g.buynum}}件</span>
							</div>
						</div>
					</div>
	</div>
	<div class='fui-list c' style="background:#f2f2f2;padding:0.2rem 0.3rem">
		<div class='fui-list-inner' ng-click="pagedata.post.goods.splice($index,1)">
			<i class="icon icon-shanchu1" style="font-size:0.6rem;color:#999"> 删除</i>
		</div>
		<div ng-class="{'fui-list-inner':1,'disabled':$index+1==pagedata.post.goods.length || pagedata.post.goods.length<=1}">
			<i class="icon icon-xiayi" ng-click="pagedata.post.goods.splice($index+2,0,g);pagedata.post.goods.splice($index,1)" style="font-size:0.6rem;color:#999"> 下移</i>
		</div>
		<div ng-class="{'fui-list-inner':1,'disabled':$index==0 || pagedata.post.goods.length<=1}">
			<i class="icon icon-shangyi" ng-click="pagedata.post.goods.splice($index-1,0,g);pagedata.post.goods.splice($index+1,1)" style="font-size:0.6rem;color:#999"> 上移</i>
		</div>
		<div class='fui-list-inner' ng-click="pagedata.op='editgoods';pagedata.goodskey=$index;pagedata.nowgoods=g">
			<i class="icon icon-bianji" style="font-size:0.6rem;color:#999"> 编辑</i>
		</div>
	</div>
</div>
<div class="weui_cells item-up-content item-ng" style="margin-top:0.5rem">
		<div class="weui_cell noborder c bold">
			<div class="weui_cell_bd weui_cell_primary" style="color:#61bba7" ng-click="pagedata.op='editgoods';pagedata.goodskey=pagedata.post.goods.length;pagedata.nowgoods={}">
				+ 添加新商品
			</div>
		</div>
</div>
<div id="selectgoods" class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
<div class="modal-dialog" style="width:100%;left:0;bottom:0">
<div class="modal-bottom" style="background:#f9f9f9;">
	<div class="fui-content" style="padding-bottom:2.5rem">
	<div class="fui-fullHigh-group" >
        <div class="fui-fullHigh-item menu" id="tab">
            <nav ng-class="{'on':pagedata.ctype =='all'}" ng-click="pagedata.getlist('all',0)">全部商品</nav>
			<nav ng-class="{'on':pagedata.ctype =='isnew'}" ng-click="pagedata.getlist('isnew',0)">新上宝贝</nav>
			<nav ng-class="{'on':pagedata.ctype =='isrecommand'}" ng-click="pagedata.getlist('isrecommand',0)">推荐宝贝</nav>
			<div ng-repeat="c1 in pagedata.category">
				<nav ng-class="{'on':pagedata.ctype ==c1.id}" ng-click="pagedata.getlist('',c1.id)" ng-show="!c1.enabled && pagedata.shopset.category.level !='-1'">{{c1.title}}</nav>
				<div ng-repeat="c2 in pagedata.category.childs[c1.id]">
					<nav ng-class="{'on':pagedata.ctype ==c2.id}" ng-click="pagedata.getlist('',c2.id)" ng-show="!c2.enabled && pagedata.shopset.category.level>=2">{{c2.title}}</nav>
					<nav ng-repeat="c3 in pagedata.category.childs[c2.id]" ng-class="{'on':pagedata.ctype ==c3.id}" ng-click="pagedata.getlist('',c3.id)" ng-show="!c3.enabled && pagedata.shopset.category.level>=3">{{c3.title}}</nav>
				</div>
			</div>
        </div>
        <div class="fui-fullHigh-item container modal-swiper-y">
				<p ng-if="pagedata.list.length<1" class="text-center text-cancel empty" style="margin-top:2rem;color:#999">暂时没有任何商品</p>
				<div class="fui-list-group goods-list-group" style="margin-top:0;">
					<div ng-repeat="g in pagedata.goods" class="fui-list goods-item" aria-hidden="true" data-dismiss="modal" ng-click="pagedata.selectgoods(g);">
							<div class="fui-list-media">
								<img ng-src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}" class='round'/>
							</div>
							<div class='fui-list-inner'>
								<div class='subtitle'>{{g.title}}</div>
								<div class='text'><span class='text-danger'>￥{{g.price}}</span></div>
								
							</div>
					</div>
				</div>
				<div ng-if="loading" class='infinite-loading'><span class='fui-preloader'></span><span class='text'> 正在加载...</span></div>
	   
        </div> 
    </div>
	<div class="fui-navbar">
		<a aria-hidden="true" data-dismiss="modal" ng-click="access_json('/merch//myshop=1')" class="nav-item btn btn-success confirmbtn">进入我的小店</a>
	</div>
	</div>
</div>
</div>
</div>
<script>
scope.loading = true;  //状态标记
scope.isnodata = false;
scope.pagedata.goods =[];
scope.pagedata.ctype ='all'
//滚动加载
scope.pagedata.params = {};
scope.pagedata.params.keyword = ''
var page = 1;
scope.pagedata.getlist=function(order,cid){
		if(order){
			page = 1;
			scope.pagedata.goods =[];
			scope.pagedata.ctype =order
		}else if(cid){
			page = 1;
			scope.pagedata.goods =[];
			scope.pagedata.ctype =cid
		}
		scope.get('jy_weishop/get_data/getgoods/page='+page+'&keyword='+scope.pagedata.params.keyword+'&order='+order+'&cid='+cid+'&frommerch=true',function(data){
					if(data.error !=1){
								for (var i=0;i<data.length;i++){
									scope.pagedata.goods.push(data[i]);
								}
								if(page >1){
									$("#goodslist").animate({scrollTop:0},300);
								}
								if(data.length<1){
									scope.isnodata=true;
								}
								page++;
								scope.loading = false;
								scope.$evalAsync();
								//getmpmansory();
							}else{
								console.log('error!');
							};
		});
}
if(scope.pagedata.isdiygoods==1){
	scope.pagedata.getlist('all',0);
	scope.pagedata.scroll_bottom=function(){
		if(!scope.isnodata && !scope.loading){
			scope.pagedata.getlist();
		}
	}
}
scope.pagedata.selectgoods=function(goodsinfo){
	if(!scope.pagedata.post.goods[0]){
		scope.pagedata.post.goods=[];
	}
	console.log(goodsinfo);
	scope.pagedata.post.goods.push({
		'title':goodsinfo.title,
		'subtitle':goodsinfo.subtitle,
		'image':goodsinfo.image,
		'unit':goodsinfo.unit,
		'price':goodsinfo.price,
		'totle':goodsinfo.totle,
	});
}
</script>